package libofei.service.impl;


import libofei.common.utils.MD5;
import libofei.dao.SysUserMapper;
import libofei.entity.sysUser.SysUser;
import libofei.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SysUserServiceImpl implements SysUserService {

    @Autowired
    private SysUserMapper sysUserMapper;


    @Override
    @Transactional
    public Long addUser(SysUser sysUser) {
        sysUser.setPassword(MD5.md5(sysUser.getPassword()));
        return sysUserMapper.addSysUser(sysUser);
    }

    @Override
    public List<SysUser> querySysUserList(SysUser sysUser) {
        return sysUserMapper.querySysUserList(sysUser);
    }

    @Override
    public SysUser querySysUserById(Long id) {
        return sysUserMapper.querySysUserById(id);
    }

    @Override
    @Transactional
    public Long updateSysUser(SysUser sysUser) {
        return sysUserMapper.updateSysUser(sysUser);
    }


    @Override
    @Transactional
    public Long updateSysUserPass(Long id, String pass) {
        return sysUserMapper.updateSysUserPass(id,pass);
    }

    @Override
    @Transactional
    public Long updateSysUserStatus(Long id, int status) {
        return sysUserMapper.updateSysUserStatus(id,status);
    }

    @Override
    public SysUser querySysUserByUsername(String username) {
        return sysUserMapper.querySysUserByUsername(username);
    }
}
